﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace SkypeBotUI
{
    public class BotConfig : ConfigurationSection
    {
        private const string configPath = "botConfig";

        private static Configuration configuration;

        static BotConfig()
        {
            configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        }

        public static BotConfig GetSection()
        {
            return (BotConfig)configuration.Sections[configPath];
        }

        public void Save()
        {
            configuration.Save(ConfigurationSaveMode.Minimal, false);
        }

        [ConfigurationProperty("rssUrl", DefaultValue = "http://bash.org.ru/rss")]
        public string RssUrl
        {
            get { return (string)this["rssUrl"]; }
            set { this["rssUrl"] = value; }
        }

        [ConfigurationProperty("lastReadMessageDate")]
        public DateTime LastReadMessageDate
        {
            get {
                DateTime property = (DateTime)this["lastReadMessageDate"];
                return property == DateTime.MinValue ? (DateTime.Now) : property;
            }
            set { this["lastReadMessageDate"] = value; }
        }

    }
}
